package org.kmp.project.main.home

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import org.kmp.project.util.showToast


class Home{

    val viewModel= HomeViewModel()

    @Composable
    fun screen(modifier: Modifier = Modifier) {

        Column(
            modifier = modifier
                .fillMaxSize()
                .padding(16.dp),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            Text(
                text = viewModel.message,
                modifier = Modifier.padding(bottom = 24.dp)
            )
            Button(onClick = {
                viewModel.incrementClickCount()
            }) {
                Text("点击我")
            }

            Button(onClick = {
                showToast("haha ${viewModel.clickCount}")
            }) {
                Text("Toast")
            }

            Button(onClick = {
                viewModel.loadData()
            }) {
                Text("网络请求测试")
            }
            Text(viewModel.userInfo)
        }
    }

}
